package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验和教训：
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P2996 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2996.class.getResource("P2996.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine().trim();
		int lineNumber = 1;
		List<Piece> white = new ArrayList<Piece>();
		List<Piece> black = new ArrayList<Piece>();
        while (line != null && line.trim().length() > 0) {
        	
        	if (lineNumber%2 == 0) {
        		String[] tmp = line.trim().split("\\|");
        		for (int i = 0; i < tmp.length; i ++) {
        			String cell = tmp[i];
        			if (cell.trim().length() == 0 || ":::".equals(cell) || "...".equals(cell)) {
        				continue;
        			} else {
        				Piece piece = new Piece();
        				piece.type = cell.charAt(1);
        				piece.col = (char)((i-1) + 'a');
        				piece.row = (char)((8-(lineNumber/2)) + '1');
        				
        				if (piece.type >= 'a' && piece.type <= 'z') {
        					black.add(piece);
        				} else if (piece.type >= 'A' && piece.type <= 'Z') {
        					white.add(piece);
        				}
        			}
        		}
        	}
        	
        	line = stdin.readLine();
        	lineNumber ++;
        }
        
        String output = "";
        output += "White: ";
        Collections.sort(white);
        for (int i = 0; i < white.size(); i ++) {
        	output += ((i==0)?"":",") + white.get(i);
        }
        output += "\n";
        output += "Black: ";
        Collections.sort(black);
        for (int i = 0; i < black.size(); i ++) {
        	output += ((i==0)?"":",") + black.get(i);
        }
        System.out.println(output);
	}

	private static class Piece implements Comparable<Piece> {
		
		private static Map<Character, Integer> order = new HashMap<Character, Integer>();
		static {
			order.put('K',  0);	order.put('k',  0);
			order.put('Q', 10);	order.put('q', 10);
			order.put('R', 20);	order.put('r', 20);
			order.put('B', 30);	order.put('b', 30);
			order.put('N', 40);	order.put('n', 40);
			order.put('P', 50);	order.put('p', 50);
		}
		
		char type;
		char col;
		char row;
		
		public int compareTo(Piece p) {
			
			if (order.get(this.type) > order.get(p.type)) {
				return 1;
			} else if (order.get(this.type) < order.get(p.type)) {
				return -1;
			} else {
				if (this.type >= 'a' && this.type <= 'z') {	//black player
					if (this.row > p.row) {
						return -1;
					} else if (this.row < p.row) {
						return 1;
					} else {
						if (this.col > p.col) {
							return 1;
						} else if (this.col < p.col) {
							return -1;
						} else {
							return 0;
						}
					}
				} else {	//white player
					if (this.row > p.row) {
						return 1;
					} else if (this.row < p.row) {
						return -1;
					} else {
						if (this.col > p.col) {
							return 1;
						} else if (this.col < p.col) {
							return -1;
						} else {
							return 0;
						}
					}
				}
			}
		}
		
		@Override
		public String toString() {
			
			if (type == 'P' || type == 'p') {
				return col+""+row;
			} else {
				return String.valueOf(type).toUpperCase()+""+col+""+row;
			}
		}
	}
}
